VS Code - Golang Debug


Delve 是 Golang 的 debug 工具,之前都沒有特別去找相關的工具,最近在翻 VS Code 的書時候才注意到這個工具,就順便紀錄一下了。


go-delve

  1. 直接照文件安裝

    $ go install github.com/go-delve/delve/cmd/dlv@latest
    
  2. 建立 launch.json (記得 mod init,不然會報錯)

    {
     // 使用 IntelliSense 以得知可用的屬性。
     // 暫留以檢視現有屬性的描述。
     // 如需詳細資訊,請瀏覽: https://go.microsoft.com/fwlink/?linkid=830387
     "version": "0.2.0",
     "configurations": [
         {
             "name": "Launch",
             "type": "go",
             "request": "launch",
             "mode": "auto",
             "program": "${fileDirname}",
             "env": {},
             "args": []
         }
     ]
    }
    
  3. 之後就可以設定中斷點,使用 F5 運行了

#golang #GO #VS Code







你可能感興趣的文章

ES5 沒有 class 那替代方法是?

ES5 沒有 class 那替代方法是?

C# 按鍵觸發事件處理

C# 按鍵觸發事件處理

筆記、[FE101] 前端基礎 盒模型與定位

筆記、[FE101] 前端基礎 盒模型與定位






留言討論